package com.zhsm.fuxi.mvp.ui.activitys

import android.content.Intent
import com.hankkin.reading.base.BaseMvpActivity
import com.zhsm.fuxi.R
import com.zhsm.fuxi.mvp.contract.AttFailedContract
import com.zhsm.fuxi.mvp.presenter.AttFailedPresenter
import kotlinx.android.synthetic.main.activity_att_failed.*
import kotlinx.android.synthetic.main.layout_head_bar.view.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by GuZhC on 2018/10/19.
 * describe:
 */
class AttFailedActivity : BaseMvpActivity<AttFailedPresenter>(), AttFailedContract.IView {

    override fun getLayoutId(): Int {
        return R.layout.activity_att_failed
    }


    override fun registerPresenter() = AttFailedPresenter::class.java


    override fun initView() {
        setMiuiStatusBar()
        attFailedHeadBar.imgLift.onClick { finish() }
        attFailedHeadBar.tvTitle.text = "实名认证"
        attAgain.onClick {
            startActivity(Intent(this@AttFailedActivity, AttActivity::class.java))
            finish()
        }
        showLoding()
        getPresenter().getAttFailedReason()
    }

    override fun setFailedReason(it: List<String>?) {
        hideLoding()
       val reason = it?.let {
            val info = StringBuilder()
            it.forEach {
                info.append(it)
                info.append("\n")
            }
            info.delete(info.length - 2, info.length).toString()
        }

        if (reason.isNullOrEmpty()) attFailedReason.text ="未知错误"
        else   attFailedReason.text =reason
    }
}